//
//  CertNetscapeType.m
//  TestProject
//
//  Created by 毕武侠 on 2022/2/20.
//  Copyright © 2022 zhulong. All rights reserved.
//

#import "CertNetscapeType.h"

@implementation CertNetscapeType

/*
 04 04(04):
    03 02(02): 00 90    (06c0)
 */
- (void)loadCertData {
    [super loadCertData];
    
    self.sslClient       = [self bit:7];
    self.sslServer       = [self bit:6];
    self.smime           = [self bit:5];
    self.objectSigning   = [self bit:4];
    self.reserved        = [self bit:3];
    self.sslCA           = [self bit:2];
    self.smimeCA         = [self bit:1];
    self.objectSigningCA = [self bit:0];
}

- (NSString *)description {
    NSMutableArray *array = [NSMutableArray array];
    if (self.sslClient == YES) {
        [array addObject:@"sslClient(SSL客户端身份验证)"];
    }
    if (self.sslServer == YES) {
        [array addObject:@"sslServer(SSL服务器身份验证)"];
    }
    if (self.smime == YES) {
        [array addObject:@"smime(SMIME)"];
    }
    if (self.objectSigning == YES) {
        [array addObject:@"objectSigning(签名)"];
    }
    if (self.sslCA == YES) {
        [array addObject:@"sslCA(SSL CA)"];
    }
    if (self.smimeCA == YES) {
        [array addObject:@"smimeCA(SMIME CA)"];
    }
    if (self.objectSigningCA == YES) {
        [array addObject:@"objectSigningCA(签名 CA)"];
    }
    
    if (array.count > 0) {
        NSMutableString *str = [NSMutableString stringWithString:@"["];
        [str appendString:[array componentsJoinedByString:@", "]];
        [str appendString:@"]"];
        return str;
    }
    return [super description];
}

@end
